#ifndef _SYSTEM_H
#define _SYSTEM_H

#include <dev.h> /* outportb () */
#include <io2.h> /* printf () */

typedef enum { on, off };

/* This defines what the stack looks like after an ISR was running */
struct regs
{
	unsigned int gs, fs, es, ds;      /* pushed the segs last */
	unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax;  /* pushed by 'pusha' */
	unsigned int int_no, err_code;    /* our 'push byte #' and ecodes do this */
	unsigned int eip, cs, eflags, useresp, ss;   /* pushed by the processor automatically */ 
};


/* Defines some system statistics */
struct {
	long uptime;			/* Seconds since boot */
	unsigned long loads[3];		/* 1, 5, and 15 minute load averages */
	unsigned long totalram;		/* Total usable main memory size */
	unsigned long freeram;		/* Available memory size */
	unsigned long sharedram;	/* Amount of shared memory */
	unsigned long bufferram;	/* Memory used by buffers */
	unsigned long totalswap;	/* Total swap space size */
	unsigned long freeswap;		/* swap space still available */
	unsigned short procs;		/* Number of current processes */
	char p[22];			/* Pads structure to 64 bytes */
} sinfo;


static void reboot (void)
{
	int i = 0;
	
	outportb (0x3f2, 0x00);
	outportb (0x64, 0xfe);
	
	/* wait some time... */
	for (; i<4000; i++);
	
	outportb (0x64, 0xff);
	
	printf ("I >>> Now rebooting the system...");
	
	/* stop interrupts and halts */
	asm ("cli;hlt");
	
	/* shouldn't be needed */
        while (1);
}

#endif
